dhcpv4: preparations for iovec usage
authorDavid Härdeman <[email protected]>
Thu, 25 Sep 2025 15:09:08 +0000 (17:09 +0200)
committerÁlvaro Fernández Rojas <[email protected]>
Tue, 21 Oct 2025 17:03:58 +0000 (19:03 +0200)
commitf87464520564ff2eb0f5636f3bc4cd36952b7ef8
treecf5e24c31c06f725656fa9d8d277bad5f6cf30c1
parentf48e1c205af3d2b3d0a35615ed5ba6fa2b280241
dhcpv4: preparations for iovec usage

dhcpv4.c currently builds DHCPv4 messages by lots of repeated calls to the
dhcpv4_put() method, which basically does a whole lot of copies to the stack.
The following set of patches convert dhcpv4.c over to use iovecs, which avoids
almost all of the stack allocations and copies.

The first step is to lay the groundwork by changing dhcpv4_send_reply() and the
corresponding dhcpv6_4o6_send_reply() in dhcpv6.c so that they both take an
iovec instead of a plain buffer. Also introduce the first (very very simple)
iovec for dhcpv4_handle_msg() which just contains the whole packet, plus the
end marker as a separate vector element. It will be filled out further in
subsequent patches.

Signed-off-by: David Härdeman <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/278
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/dhcpv4.c
src/dhcpv6.c
src/odhcpd.h